home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / clib / stricmp.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  72 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: stricmp.c,v 1.2 1996/10/19 16:56:29 aros Exp $
  4.  
  5.     Desc: C function stricmp() and strcasecmp()
  6.     Lang: english
  7. */
  8. #include <ctype.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13.     #include <string.h>
  14.  
  15.     int strcasecmp (
  16.  
  17. /*  SYNOPSIS */
  18.     const char * str1,
  19.     const char * str2)
  20.  
  21. /*  FUNCTION
  22.     Calculate str1 - str2 ignoring case.
  23.  
  24.     INPUTS
  25.     str1, str2 - Strings to compare
  26.  
  27.     RESULT
  28.     The difference of the strings. The difference is 0, if both are
  29.     equal, < 0 if str1 < str2 and > 0 if str1 > str2. Note that
  30.     it may be greater then 1 or less than -1.
  31.  
  32.     NOTES
  33.     This function is not part of a library and may thus be called
  34.     any time.
  35.  
  36.     EXAMPLE
  37.  
  38.     BUGS
  39.  
  40.     SEE ALSO
  41.  
  42.     INTERNALS
  43.  
  44.     HISTORY
  45.     24-12-95    digulla created
  46.  
  47. ******************************************************************************/
  48. {
  49.     int diff;
  50.  
  51.     /* No need to check *str2 since: a) str1 is equal str2 (both are 0),
  52.     then *str1 will terminate the loop b) str1 and str2 are not equal
  53.     (eg. *str2 is 0), then the diff part will be FALSE. I calculate
  54.     the diff first since a) it's more probable that the first chars
  55.     will be different and b) I don't need to initialize diff then. */
  56.     while (!(diff = tolower (*str1) - tolower (*str2)) && *str1)
  57.     {
  58.     /* advance both strings. I do that here, since doing it in the
  59.         check above would mean to advance the strings once too often */
  60.     str1 ++;
  61.     str2 ++;
  62.     }
  63.  
  64.     /* Now return the difference. */
  65.     return diff;
  66. } /* strcasecmp */
  67.  
  68. int stricmp (const char * s1, const char * s2)
  69. {
  70.     return strcasecmp (s1, s2);
  71. }
  72.